<template>
<el-form-item label="主体类别">
    <el-select v-model="subjectCode" @focus="mainType" filterable placeholder="请选择">
        <el-option v-for="item in subjectList" :key="item.value" :label="item.label" :value="item.value">
        </el-option>
    </el-select>
</el-form-item>
</template>

<script>
export default {
    components: {},
    data: () => ({
        subjectList: [],
        subjectCode: "",
    }),
    created() {
        this.mainType()
    },
    methods: {
        mainType() {
            if (this.subjectList.length) {
                return false
            }
            this.$common
                .selectPage({
                    ptCode: "P02",
                    pageNumber: 1,
                    pageSize: 5,
                })
                .then((res) => {
                    if (res.errorCode === "00000") {
                        res.data.list.forEach((item) => {
                            this.subjectList.push({
                                label: item.propertyValue,
                                value: item.pvCode
                            })
                        })
                        this.subjectCode = this.subjectList[0].value
                    }
                });
        },
    },
    watch: {
        subjectCode: {
            handler(n,o) {
                this.$emit('on-change', n)
            },
            deep: true
        }
    },
};
</script>

<style></style>
